package com.laozhao.deliveryManager.test;

/** 
 * 引入JCom操作Excel的jar 
 */
import jp.ne.so_net.ga2.no_ji.jcom.ReleaseManager;
import jp.ne.so_net.ga2.no_ji.jcom.excel8.ExcelApplication;
import jp.ne.so_net.ga2.no_ji.jcom.excel8.ExcelWorkbook;
import jp.ne.so_net.ga2.no_ji.jcom.excel8.ExcelWorkbooks;
import jp.ne.so_net.ga2.no_ji.jcom.excel8.ExcelWorksheet;

/**
 * 预览Excel的类
 * 
 * @author tianmaochun
 * 
 */
public class PrintViewExcel {

	/**
	 * 实线Excel预览的类
	 * 
	 * @param fileName
	 *            [图片的路径]
	 * 
	 */
	public void getExcelView(String fileName) {
		ReleaseManager rm = new ReleaseManager();
		try {
			// 创建可加载的组件
			ExcelApplication excel = new ExcelApplication(rm);
			// 创建工作薄对象
			ExcelWorkbooks xlBooks = excel.Workbooks();
			// 打开工作薄
			ExcelWorkbook xlBook = xlBooks.Open(fileName);
			// 打印
			ExcelWorksheet xlSheet = excel.ActiveSheet();
			// 显示Excel
			excel.Visible(true);
			// 输出页面
			xlSheet.PrintOut(1, 1, 1, true);
			// 关闭
			xlBook.Close(false, null, false);
			excel.Quit();
		} catch (Exception e) {
			e.printStackTrace();

		} finally {
			rm.release();
		}
	}

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		PrintViewExcel prview = new PrintViewExcel();
		prview.getExcelView("D:\\CrazyCode\\DeliveryManager\\temp\\delivery_order.xls");

	}

}
